package com.jwt.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jwt.utils.JwtUtils;

import io.jsonwebtoken.Claims;

@RestController
public class UserController {

	@Autowired
	private JwtUtils jwtUtils;

	@RequestMapping("/")
	public String getToken() {
		
		Map<String, Object> map = new HashMap<>();
		map.put("name", "李思思");
		map.put("age", 25);

		String token = jwtUtils.createJwt("521", "张三", map);
		
		Claims parseJwt = jwtUtils.parseJwt(token);
		return token+" ---- "+parseJwt.toString();

		
	}
}
